home *** CD-ROM | disk | FTP | other *** search
- Path: cs.tu-berlin.de!news
- From: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Is there a standard for * and & placement style?
- Date: 28 Feb 1996 02:50:55 GMT
- Organization: Technical University of Berlin, Germany
- Message-ID: <4h0fuf$pru@news.cs.tu-berlin.de>
- NNTP-Posting-Host: 130.149.17.236
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
-
- gema001@pn.itnet.it (Antonio Romeo) writes:
- > >...
- > >-- use intelligent variable names
- > >...
- >
- > a bit more on this:
- >
- > intelligent variables names are meaningfull names.
- > So
- >
- > int i; /* loop counter */
- >
- > ...
- >
- > for (i=0;i<MAX; i++)
- > MakeOnArray(arrayname[i]);
- > ...
- >
- > does not is a good name. In a loop, i is the current processed element
- > of an array, the next or the previous?
- > Another good practice is to not make
- > assumption on variable values after al loop, expecialli in a FOR
- > statement. This is true for every language I know. The variable value
- > after a loop depend on compiler (not language) decision.
- >
-
- As far as I remember the FOR loop is specified as follows:
-
- for( expr1; expr2; expr3 )
- statement
-
- is equivalent to
-
- expr1;
- while( expr2 )
- {
- statement
- expr3;
- }.
-
- This means that you may perfectly rely on the value of EVERY variable as long
- as your expr2 depends on it somehow. For instance, in
-
- for( i=0; i<10; ++i );
-
- i=10 after the loop. It does not depend on the compiler.
-
- Bye
-
- Roman
-